<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf"> 奖品列表</div>
                </div>
                <div class="widget-body am-fr">
                    <!-- 工具栏 -->
                    <div class="page_toolbar am-margin-bottom am-cf">
                        <form class="toolbar-form" action="">
                            <input type="hidden" name="s" value="">
                            <div class="am-u-sm-12 am-u-md-3">
                                <div class="am-form-group">
                                    <div class="am-btn-toolbar">
                                        <?php if (checkPrivilege('apps.lottery.action/addGoods')): ?>
                                            <div class="am-btn-group am-btn-group-xs">
                                                <a class="am-btn am-btn-default am-btn-success am-radius"
                                                   href="<?= url('apps.lottery.action/addGoods', ['lottery_id' => $id]) ?>">
                                                    <span class="am-icon-plus"></span> 新增
                                                </a>
                                            </div>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="am-scrollable-horizontal am-u-sm-12">
                        <table width="100%" class="am-table am-table-compact am-table-striped
                         tpl-table-black am-text-nowrap">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>奖品名称</th>
                                <th>奖品logo</th>
                                <th>奖品类型</th>
                                <th>中奖值（万分比）</th>
                                <th>库存</th>
                                <th>中奖率（万分比）</th>
                                <th>排序</th>
                                <th>创建时间</th>
                                <th>更新时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php if ($list): foreach ($list as $item): ?>
                                <tr>
                                    <td class="am-text-middle"><?= $item['id'] ?></td>
                                    <td class="am-text-middle"><?= $item['name'] ?></td>
                                    <td class="am-text-middle">
                                        <a href="<?= $item['logo']['file_path'] ?>"
                                           title="点击查看大图" target="_blank">
                                            <img src="<?= $item['logo']['file_path'] ?>"
                                                 width="50" height="50" alt="奖品logo">
                                        </a>
                                    </td>
                                    <td class="am-text-middle"><?= $item['type']['value'] ?></td>
                                    <td class="am-text-middle"><?= $item['value'] ?></td>
                                    <td class="am-text-middle"><?= $item['num'] ?></td>
                                    <td class="am-text-middle"><?= $item['value'] * $item['num'] ?></td>
                                    <td class="am-text-middle"><?= $item['sort'] ?></td>
                                    <td class="am-text-middle"><?= $item['create_time'] ?></td>
                                    <td class="am-text-middle"><?= $item['update_time'] ?></td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <?php if (checkPrivilege('apps.lottery.action/editGoods')): ?>
                                                <a href="<?= url('apps.lottery.action/editGoods', ['id' => $item['id']]) ?>"
                                                   class="item-inner tpl-table-black-operation-default">
                                                    <i class="am-icon-pencil"></i> 编辑奖品
                                                </a>
                                            <?php endif; ?>
                                            <?php if (checkPrivilege('apps.lottery.action/deleteGoods')): ?>
                                                <a href="javascript:void(0);"
                                                   class="item-delete tpl-table-black-operation-default"
                                                   data-id="<?= $item['id'] ?>">
                                                    <i class="am-icon-trash"></i> 删除
                                                </a>
                                            <?php endif; ?>
                                        </div>
                                    </td>
                                </tr>
                            <?php endforeach; else: ?>
                                <tr>
                                    <td colspan="9" class="am-text-center">暂无记录</td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(function () {

        // 删除元素
        var url = "<?= url('apps.lottery.action/deleteGoods') ?>";
        $('.item-delete').delete('id', url);

    });
</script>

